﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PHTShop.admin
{
    public partial class createPartner : System.Web.UI.Page
    {
        private DataContextDataContext dc = new DataContextDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Create partner";
            if (!IsPostBack)
            {

                loadData();
            }


        }

        private void loadData() {

            ListView1.DataSource = dc.Partners.Where(z => z.status == true); ;
            ListView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string partnerName = TextboxPartnerName.Value.Trim();
                string detail = TextboxDescription.Value.Trim();

                dc.Partners.InsertOnSubmit(new Partner
                {
                    name = partnerName,
                    details = detail,
                    status=true,
                });
                dc.SubmitChanges();
                TextboxPartnerName.Value = "";
                TextboxDescription.Value = "";
                loadData();
            }
        }
    }
}